package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
                //1.打印提示信息 欢迎来到猜数字
                System.out.println("欢迎来到猜数字");
                //2.生成数字
                int anser =  (int) (Math.random()*100+1);
                System.out.println(anser);
                //3.猜测数字
                Scanner num = new Scanner(System.in);
                int chances = 55;
                while(chances>0){
                    //规定猜测次数
                    System.out.println("请输入 1-100之间数字 "+"你还有"+chances+"机会");
                    int guess = num.nextInt();
                    //4.比较并完成
                    if(guess>anser){
                        System.out.println("猜大了");
                    } else if (guess<anser) {
                        System.out.println("猜小了");
                    }else{
                        System.out.println("猜对了");
                        break;
                    }

                    chances --;



        }

    }
}
